extends Control

@export var saver: SaveHandler

func _ready():
	unpause()

func _unhandled_input(event):
	if event.is_action_pressed("ui_cancel"):
		if $"../..".paused:
			unpause()
		else:
			pause()

func unpause():
	$Menu.visible = false
	$"../HotBar".visible = true
	$"../..".paused = false
	Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

func pause():
	$Menu.visible = true
	$"../HotBar".visible = false
	$"../..".paused = true
	Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)




func _on_back_to_game_button_pressed():
	unpause()


func _on_quit_to_title_button_pressed():
	unpause()
	Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
	get_tree().change_scene_to_file("res://scenes/main.tscn")


func _on_quit_to_os_button_pressed():
	unpause()
	get_tree().quit()


func _on_save_button_pressed():
	saver.save_file()
